# 最低 CMake 版本要求
cmake_minimum_required(VERSION 3.10)
# 检查内存 valgrind --leak-check=full ./event_server
# g++ -o client client.cpp -ljsoncpp -lpthread -std=c++11
# 项目名称
project(event_server LANGUAGES CXX)

# 设置 C++ 标准
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# 3. 查找 pthread（Threads）库
find_package(Threads REQUIRED)
# 查找 JsonCpp 库
find_package(jsoncpp REQUIRED)

include_directories(/usr/include/jsoncpp)
# 查找 JsonCpp 库文件
find_library(JSONCPP_LIBRARY jsoncpp)
if(NOT JSONCPP_LIBRARY)
    message(FATAL_ERROR "JsonCpp library not found!")
endif()


# 添加头文件搜索路径
include_directories(${PROJECT_SOURCE_DIR}/include)

# 查找 src 目录下的所有源文件
aux_source_directory(${PROJECT_SOURCE_DIR}/src SOURCES)

# 设置可执行文件输出路径
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)

# 添加可执行文件
add_executable(
    event_server
    ${SOURCES}
)

# 链接 pthread（Threads）库
target_link_libraries(event_server
    PRIVATE Threads::Threads
)
# 链接 JsonCpp 库
target_link_libraries(event_server PRIVATE ${JSONCPP_LIBRARY})